package cn.cdeden.knowledge.service;



import cn.cdeden.common.core.utils.page.TableDataInfo;
import cn.cdeden.common.satoken.utils.LoginHelper;
import cn.cdeden.knowledge.domain.TeamMember;
import cn.cdeden.knowledge.domain.dto.TeamMemberDto;
import cn.cdeden.knowledge.domain.dto.TeamMemberQueryParam;
import cn.cdeden.knowledge.domain.dto.UserHideInfoDto;
import cn.cdeden.system.api.model.LoginUser;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.data.domain.Pageable;

import java.util.List;
import java.util.Set;

/**
 * @author Chen
 * @date 2022-09-06
 */
public interface TeamMemberService extends IService<TeamMember> {

    static final String CACHE_KEY = "teamMember";

    /**
     * 查询数据分页
     *
     * @param query    条件
     * @param pageable 分页参数
     * @return PageInfo<TeamMemberDto>
     */
    TableDataInfo<TeamMemberDto> queryAll(TeamMemberQueryParam query, Pageable pageable);

    /**
     * 查询所有数据不分页
     *
     * @param query 条件参数
     * @return List<TeamMemberDto>
     */
    List<TeamMemberDto> queryAll(TeamMemberQueryParam query);


    List<TeamMemberDto> getTeamByMemberDto(Long userId);

    List<TeamMemberDto> getMemberByTeamId(Integer teamId);

    void headNodeExtendTeamMember(TeamMemberDto teamMemberDto, String teamId, String headNodeId);

    boolean addMembers(List<TeamMemberDto> teamMemberDtos);

    boolean delete(TeamMemberDto teamMemberDto);

    TeamMember getById(Integer id);

    /**
     * 插入一条新数据。
     */
    int insert(TeamMemberDto resources);

    int updateById(TeamMemberDto resources);

    int updateByUserId(Integer teamId, Long objectId,int objectType,String roleId);

    int removeById(Integer id);

    int removeByIds(Set<Integer> ids);

    /**
     * 鉴权方法 根据权限code判断用户是否在该团队拥有此权限
     * @param teamId 团队id
     * @param user 用户对象
     * @param param 需要鉴权的权限code
     * @return
     */
    Boolean checkPermission(String teamId, LoginUser user, String param);

    /**
     * 查询出用户在该团队所拥有成员对象
     * @param teamId 团队id
     * @param user 用户对象
     * @return
     */
    List<TeamMemberDto> getRole(String teamId, LoginUser user);

    List<TeamMemberDto> getByRoleId(Long id);

    Set<UserHideInfoDto> queryUser(TeamMemberQueryParam query);

    /**
     * 导出数据
     * @param all 待导出的数据
     * @param response /
     * @throws IOException /
     */
    // void download(List<TeamMemberDto> all, HttpServletResponse response) throws IOException;
}
